<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="./css/loading.css">
  <link rel="stylesheet" href="./css/vue2-animate.min.css">
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <link rel="stylesheet" href="https://unpkg.com/mint-ui/lib/style.css">
  <link rel="stylesheet" href="./css/rose.css">
  <link rel="stylesheet" href="./css/footer.css">
</head>
<body>
  <div id="appLoading">
   <img src="./images/loading.gif" width="50px" height="50px">
   <div class="loading-text">加载中......</div>
  </div>
  <div id="Rose" style="display: none">
    <el-container>
      <el-header>掌上种植</el-header>
      <el-main>
        <div class="ros-msg">
          <div>爱心值： {{rose.RoseHP}}</div>
          <div>经验值： {{rose.RoseEXP}}</div>
        </div>
        <transition name="bounce"
          enter-active-class="bounceInDown"
          leave-active-class="bounceOutDown">
          <div class="ros-sign" v-if="show" ref="sign">
            {{text}} +
          </div>
        </transition>
        <div class="ros-rose">
          <img src="./images/icon/rose.png" alt="">
        </div>
        <div class="ros-function">
          <el-button v-for="btn in roseBtn" :type="btn.size" @click.native="RoseFunction(btn)">{{btn.name}}</el-button>
          <br>
          <el-button style="margin-top:20px;">掌上百科</el-button>
        </div>
      </el-main>
      <el-footer>
        <div class="footer">
          <ul>
            <li>
              <div class="foo-icon f-p1"></div>
              <div class="foo-name">商店</div>
            </li>
            <li>
              <div class="foo-icon f-p2"></div>
              <div class="foo-name">分类</div>
            </li>
            <li>
              <div class="foo-icon f-p3"></div>
              <div class="foo-name">玫瑰花</div>
            </li>
            <li>
              <div class="foo-icon f-p4"></div>
              <div class="foo-name">购物车</div>
            </li>
            <li>
              <div class="foo-icon f-p5"></div>
              <div class="foo-name">个人中心</div>
            </li>
          </ul>
        </div>
      </el-footer>
    </el-container>
  </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/mint-ui/lib/index.js"></script>
<script type="text/javascript">
  new Vue({
    el: "#Rose",
    data(){
      return {
        text: null,
        rose: {
          RoseHP: 1222,
          RoseEXP: 20
        },
        roseBtn: [
          {
            name: "施肥",
            type: "fertilize",
            size: "primary"
          },
          {
            name: "浇水",
            type: "watering",
            size: "success"
          },
          {
            name: "修剪",
            type: "build",
            size: "warning"
          }
        ],
        show: false,
        sign: "sign",
        roseFunc: {
          fertilize: 5,
          watering: 6,
          build: 4
        }
      }
    },
    methods: {
      RoseFunction(item){
        console.log(this.roseFunc[item.type]);
        this.text = item.name;
        this.show = !this.show;
        this.rose.RoseHP -= this.roseFunc[item.type];
        this.rose.RoseEXP += this.roseFunc[item.type];
        setTimeout(() => this.show = !this.show,1000);
        // axios.post("...", {
        //   RoseHP: this.rose.RoseHP,
        //   RoseEXP: this.rose.RoseEXP
        // })
        // .then((res)=>{
        //   //可以把上面那些操作放进来
        // })
        // .catch((err) => {
        //   console.log(res);
        //   this.$messagebox.alert("操作失败","提示")
        // })
      }
    },
    // computed: {
    //   Rose(){
    //     return {
    //       RoseHP: 1222,
    //       RoseGrade: 1,
    //       RoseEXP: 20
    //     }
    //   }
    // },
    mounted(){
     document.getElementById('Rose').style.display = 'block';
     document.getElementById('appLoading').style.display = 'none';
     // axios.get(....)
     // .then((res)=>{
     //   //data 里的rose 是爱心值和经验值存放对象
     //   // data 里的roseFunc 不同的操作扣减的不同的爱心值。
     // })
    }
  })
</script>
</html>
